library(knitr)
## Warning: package 'knitr' was built under R version 4.1.3
opts_chunk$set(tidy.opts = list(width.cutoff = 60))
opts_knit$set(global.par = TRUE)
Load Zambia’s ministry of agriculture maize forecasts data as reference.
Load data
## [1] "Province" "District" "planted_ha" "harvested_ha"
## [5] "production_MT" "yield_MT_ha" "Year"
Convert District and province names to upper case.
## [1] "CENTRAL" "COPPERBELT" "EASTERN" "LUAPULA"
## [5] "LUSAKA" "MUCHINGA" "NORTH-WESTERN" "NORTHERN"
## [9] "SOUTHERN" "WESTERN"
| x |
|---|
| CHADIZA |
| CHAMA |
| CHAVUMA |
| CHIBOMBO |
| CHIENGE |
| CHILILABOMBWE |
Visualize the crop forecasting data from MoA per year.
boxplot(yield_MT_ha~Year, data=ref, col=rainbow(length(unique(ref$Year))), xlab="Year", ylab = "Yield (MT/ha)", main="Zambia MoA Annual Forecasts.")
Visualize the crop forecasting data from MoA per Province.
Aggregate MoA forecasts per district.
Load and aggregate RHEAS simulated Leaf Area Index (LAI), Water stress and Grain Weight Average Dry (GWAD) across different ensembles. Extract year from dates (we will use harvest year).
Aggregate RHEAS production forecasts and metrics with respect to Districts maize growing calendar.
The maize growing season in Zambia starts from October to end of
June. So we will aggregate the metrics and forecast with this condition
using the function RH_metrics.
Convert RHEAS yields from kg/ha to MT/ha.
Add shapefile for visualization.
Check and format District names to be consistent in both the RHEAS and administrative boundaries.
## character(0)
## character(0)
Merge RHEAS and Admin data.
Visualize RHEAS predicted yields spatially.
Compare RHEAS with MoA forecasts.
Merge the MoA forecasts with RHEAS ones by year and District.
We can use the Root Mean Square Error (RMSE) and mean absolute percentage error (MAPE) to evaluate the models accuracy. RMSE is given as:
\[ \text{RMSE} = \sqrt{\frac{1}{n} \sum_{i=1}^n y-\widehat{y}}, \] where \(\widehat{y}\) and \(y\) are predicted yields and observed yields respectively while n is the number of fitted points.
Compute RMSE.
## RMSE 1.010225
What about Relative root mean square error (RRMSE):
\[ \text{RRMSE} = \frac{\sqrt{\frac{1}{n} \sum_{i=1}^n y-\widehat{y}}}{\frac{1}{n} \sum_{i=1}^n y}, \]
Compute RRMSE.
## RRMSE 46.70591
According to Li et al. 2013, the performance of the model is excellent when RRMSE < 10%; good if 10% < RRMSE < 20%; fair if 20% < RRMSE < 30%; and poor if RRMSE ≥ 30%.